package lastcontrnt.memoryleak;

import java.util.ArrayList;
import java.util.List;

/**
 * 内存泄漏3 外部类方法返回内部类对象
 */
public class Leak3 {
    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();
        int counter = 0;
        while (true) {
            list.add(new Outer(100000).createInner());
            System.out.println(counter++);
        }
    }
}

class Outer{
    private int[] data;

    public Outer(int size) {
        this.data = new int[size];
    }

    class Innner{

    }

    Innner createInner() {
        return new Innner();
    }
}